//
//  MZYsurplusViewController.m
//  WristWatch
//
//  Created by dllo on 15/10/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MZYsurplusViewController.h"
#import "MZYsurTableViewCell.h"
#import "MZYshowViewController.h"
#import "MZYupdateViewController.h"

@interface MZYsurplusViewController ()<UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, retain)UITableView *tableView;


@end

@implementation MZYsurplusViewController

- (void)dealloc {
    [_tableView release];

    
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createView];
}

- (void)createView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT / 2.5) style:UITableViewStylePlain];
    self.tableView.rowHeight = 80;
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    [_tableView release];
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuse = @"reuse";
    MZYsurTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[MZYsurTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse] autorelease];
    }
    if (indexPath.row == 0) {
        cell.surLabel.text = @"最新发布";
        cell.surImageView.image = [UIImage imageNamed:@"8.jpg"];
    } else {
        cell.surLabel.text = @"show time";
        cell.surImageView.image = [UIImage imageNamed:@"9.jpg"];
    }
//    cell.backgroundColor = [UIColor whiteColor];
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"555");
    if (indexPath.row == 0) {
        MZYupdateViewController *newsVC = [[MZYupdateViewController alloc] init];
        [self.navigationController pushViewController:newsVC animated:YES];
        [newsVC release];
    } else {
        MZYshowViewController *upVC = [[MZYshowViewController alloc] init];
        [self.navigationController pushViewController:upVC animated:YES];
        [upVC release];
    }
}










- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
